var nativeWebview, imm, InputMethodManager;
var initNativeObjects = function() {
    if (mui.os.android) {
        var main = plus.android.runtimeMainActivity();
        var Context = plus.android.importClass("android.content.Context");
        InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
        imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
    } else {
        nativeWebview = plus.webview.currentWebview().nativeInstanceObject();
    }
};
var showSoftInput = function() {
    if (mui.os.android) {
        imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
    } else {
        nativeWebview.plusCallMethod({
            "setKeyboardDisplayRequiresUserAction": false
        });
    }
    setTimeout(function() {
       //此处可写具体逻辑设置获取焦点的input
       var inputElem = document.querySelector('input');
              inputElem.focus(); 
    }, 200);
};

// var showSoftInput = function() {
//     var nativeWebview = plus.webview.currentWebview().nativeInstanceObject();
//     if (mui.os.android) {
//         //强制当前webview获得焦点
//         plus.android.importClass(nativeWebview);
//         nativeWebview.requestFocus();
//         imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
//     } else {
//         nativeWebview.plusCallMethod({
//             "setKeyboardDisplayRequiresUserAction": false
//         });
//     }
//     setTimeout(function() {
//        //此处可写具体逻辑设置获取焦点的input
//        var inputElem = document.querySelector('input');
//               inputElem.focus(); 
//     }, 200);
// };